const { codeFrameColumns } = require('@babel/code-frame')

const rawLines = `class Foo {
  constructor(){ console.log("hello");}
}`;
const location = { start: { line: 2, column: 4 } };

const result = codeFrameColumns(rawLines, location, {
  /* options */
});

console.log(result);